package cn.xfdzx.android.apps.shop.util;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.youth.banner.loader.ImageLoader;

/**
 * @author gzk
 * @date 2020/4/17 0017
 * description：
 */
public class GlideImageLoader extends ImageLoader {
    @Override
    public void displayImage(Context context, Object path, ImageView imageView) {

//        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
//        //Glide 加载图片简单用法
//        Glide.with(context).load(path).into(imageView);
        imageView.setImageResource(((GlideImageLoader.BannerItem) path).pic);
//        //设置图片圆角角度
//        RoundedCorners roundedCorners = new RoundedCorners(10);
//        //通过RequestOptions扩展功能,override:采样率,因为ImageView就这么大,可以压缩图片,降低内存消耗
//        // RequestOptions options = RequestOptions.bitmapTransform(roundedCorners).override(300, 300);
//        RequestOptions options = RequestOptions.bitmapTransform(roundedCorners);
//        Glide.with(context).load(path).apply(options).into(imageView);
    }

    public static class BannerItem {

        public int pic;

        public BannerItem() {
        }

        public BannerItem(int pic) {
            this.pic = pic;
        }
    }
}
